package cn.edu.xjtu.android.emoji_warfare_android.game;

import android.graphics.Canvas;
import cn.edu.xjtu.android.emoji_warfare_android.engine.entity.Entity;
import cn.edu.xjtu.android.emoji_warfare_android.engine.entity.Point;

/**
 * 盾牌
 * 
 * @author bill
 *
 */
public class Sheild extends Entity {
    public static long stopTime;
    Point p;
    int imageIndex;

    public Sheild(float birthX, float birthY) {
        super(birthX, birthY, Config.Sheild.outline);
        imageIndex = 0;
        p = Engine.instance.getDefaultController().player.basePoint;
    }

    public Sheild() {
        this(0, 0);
    }

    @Override
    public boolean onDraw(Canvas canvas) {
        basePoint.x = p.x;
        basePoint.y = p.y;
        canvas.drawBitmap(Config.Sheild.sheildBase, -Config.Sheild.len / 2.0f, -Config.Sheild.len / 2.0f,
                Config.Common.bitmapPaint);
        canvas.drawBitmap(Config.Sheild.lightImage[imageIndex++], -Config.Sheild.len / 2.0f, -Config.Sheild.len / 2.0f,
                Config.Common.bitmapPaint);
        imageIndex %= Config.Sheild.lightImageCount;
        if (Engine.instance.clock() > stopTime) {
            Engine.instance.getDefaultController().player.stopSheild();
        }
        return false;
    }
}
